﻿Public Class NewProduct

    Private Sub NewProduct_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub BtnAddProduct_Click(sender As System.Object, e As System.EventArgs) Handles BtnAddProduct.Click
        Dim values As New Dictionary(Of String, String)

        If TxtColour.Text.Length < 1 Or TxtMaterial.Text.Length < 1 Or TxtProductName.Text.Length < 1 Or TxtSize.Text.Length < 1 Or TxtValue.Text.Length < 1 Then
            MsgBox("All fields required")
        Else
            values.Add("name", TxtProductName.Text)
            values.Add("material", TxtMaterial.Text)
            values.Add("colour", TxtColour.Text)
            values.Add("size", TxtSize.Text)
            values.Add("value", TxtValue.Text)

            Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()
            databaseProvider.InsertProduct(values)
            Product.ProductDataGrid.DataSource = databaseProvider.GetAllProducts()
        End If

    End Sub

    Private Sub BtnClose_Click(sender As System.Object, e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub
End Class